home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Archive / Graphics / QuickDraw GX / GX->PostScript Sample / GXToPostScript / GXtoPSHeaders / GXPrintingUniverse.h next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  9.5 KB  |  232 lines  |  [TEXT/CWIE]

  1. /*
  2.      File:        GXPrintingUniverse.h
  3.  
  4.      Contains:    QuickDraw GX to PostScript conversion code.
  5.                      definitions
  6.  
  7.     This file includes definitions necessary for the GX->PostScript library.
  8.  
  9.     Since these types came from the GX public headers
  10.     Documentation for these types and structures are available in "Inside Mac: GX Printing" and 
  11.     "Inside Mac: GX Printing Extensions and Drivers"
  12.         
  13.     Version:    Technology:    Quickdraw GX 1.1.x
  14.       
  15.      Copyright:    © 1994-1997 by Apple Computer, Inc., all rights reserved.
  16. */
  17.  
  18. #ifndef __GXPRINTINGUNIVERSE__
  19. #define __GXPRINTINGUNIVERSE__
  20.  
  21. #include <GXFonts.h>
  22. #include <GXGraphics.h>
  23. #include "GXToPSBuildConfig.h"
  24. #include <CMApplication.h>
  25.  
  26. typedef void*    TFile;                    // temp, until I get to this DL 7/26/87
  27.  
  28. #define printingBaseID -27000
  29.  
  30. /* Options for gxBufferData message */
  31.  
  32. enum {
  33.     gxNoBufferOptions            = 0x00000000,
  34.     gxMakeBufferHex                = 0x00000001,
  35.     gxDontSplitBuffer                = 0x00000002
  36. };
  37.  
  38.  
  39. #define kScriptResType FOUR_CHAR_CODE('STR#')
  40.  
  41.  
  42. enum {
  43.     gxPrintingResultBase        = -510                            /*First QuickDraw GX printing error code.*/
  44. };
  45.  
  46. /*RESULT CODES FOR QUICKDRAW GX PRINTING OPERATIONS*/
  47.  
  48. enum {
  49.     gxPrUserAbortErr            = (gxPrintingResultBase - 26),    /*-536 : User aborted*/
  50.     gxIncompletePrintFileErr    = (gxPrintingResultBase - 35),    /*-545 : Print file was not completely spooled*/
  51.     gxNotEnoughPrinterMemory    = (gxPrintingResultBase - 45),    /*-555 : Printer does not have enough memory for fonts in document*/
  52. };
  53.  
  54.  
  55.  
  56. /* ------------------------------------------------------------------------------
  57.  
  58.                             PostScript Driver Contants and Types
  59.  
  60. -------------------------------------------------------------------------------- */
  61.  
  62. enum {
  63.     gxPostSynonym                = FOUR_CHAR_CODE('post')
  64. };
  65.  
  66. /* PostScript glyphs record */
  67. struct gxPrinterGlyphsRec {
  68.  
  69.     gxFont                         theFont;                    /*  ---> Font reference */
  70.     long                             nGlyphs;                    /*  ---> Number of glyphs in the font */
  71.     gxFontPlatform         platform;                    /* <---  How printer font is encoded, gxGlyphPlatform unless font is not 8-bit reencodable such as Kanji fonts
  72.                                                                                             in that case put the gxJapaneseFontPlatform, for exampe */
  73.     gxFontScript             script;                        /* <---  Script if platform != glyphPlatform */
  74.     gxFontLanguage         language;                    /* <---  Language if platform != glyphPlatform */
  75.     long                             vmUsage;                    /* <---  How much PostScript VM font uses */
  76.  
  77.                                                                         /* Size of this array is long-alligned(nGlyphs) */
  78.     unsigned long             glyphBits[1];                /* <---  Bit array of which system glyphs are in printer */
  79.  
  80. };
  81. typedef struct gxPrinterGlyphsRec gxPrinterGlyphsRec;
  82.  
  83.  
  84. /* PostScript device rendering information */
  85. enum {
  86.     gxNeedsHexOption                        = 0x00000001,                    /* Convert all binary data to hex */
  87.     gxNeedsCommentsOption            = 0x00000002,                    /* Issue PostScript comments */
  88.     gxBoundingBoxesOption                = 0x00000004,                    /* Calculate the values for */
  89.     gxPortablePostScriptOption        = 0x00000008,                    /* Generate portable PostScript */
  90.     gxTextClipsToPathOption            = 0x00000010,                    /* Convert all clips that are composed of text to path shapes */
  91.  
  92.     /* Note, these two were never implemented, going way, way back, but I'll leave them in the enum anyway */
  93.     gxFlattenClipPathOption                = 0x00000020,                    /* Convert all clips that are path shapes to polygons (helps better control point limit) */
  94.     gxUseCharpath1Option                = 0x00000040,                    /* (ignored if text clips are converted to paths)  When the clip is text,  */
  95.                                                                                                 /* Do it one glyph at a time, redrawing the main shape each time */
  96.                                                                                                 
  97.     gxUseLevel2ColorOption            = 0x00000080,                    /* When printing to level-2 use level-2 device independent color */
  98.  
  99.     gxNoEPSIllegalOperators            = 0x00000100,                    /* Don't use any operators prohibited by the Encapsulated PostScript File Format V3.0 */
  100.     gxPageIndependentPostScript    = 0x00000200,                    /* Don't generate PostScript with page interdependencies */
  101.     
  102.                 /* PostScript intended for EPS Use. */
  103.     gxEPSTargetOption                    =    gxPageIndependentPostScript +
  104.                                                         gxNoEPSIllegalOperators +
  105.                                                         gxNeedsCommentsOption +
  106.                                                         gxBoundingBoxesOption, 
  107. };
  108.  
  109. typedef long                             gxPostScriptRenderOptions;
  110.  
  111. struct gxPostScriptImageDataRec {
  112.     short                                         languageLevel;                /* PostScript language level */
  113.     gxColorSpace                             devCSpace;                    /* The printer's color space */
  114.     gxColorProfile                             devCProfile;                    /* The printer's color profile for matching */
  115.     gxPostScriptRenderOptions         renderOptions;                /* Options for the imaging system */
  116.     long                                             pathLimit;                        /* Maximum path size */
  117.     short                                         gsaveLimit;                    /* Maximum number of gsaves allowed */
  118.     short                                         opStackLimit;                /* Operand stack limit */
  119.     scalerStreamTypeFlag                 fontType;                        /* These are the font types that the printer supports  */
  120.     long                                             printerVM;                    /* How much memory is in the printer */
  121.     long                                             reserved0;
  122. };
  123. typedef struct gxPostScriptImageDataRec gxPostScriptImageDataRec;
  124.  
  125.  
  126.  
  127.  
  128. typedef gxPostScriptImageDataRec *        gxPostScriptImageDataPtr;
  129.  
  130.  
  131. struct gxFormatHalftoneInfo {
  132.     long                                     numHalftones;                /* Number of halftone records */
  133.     gxHalftone                         halftones[1];                /* The halftone records */
  134. };
  135. typedef struct gxFormatHalftoneInfo gxFormatHalftoneInfo;
  136.  
  137. enum {
  138.     gxFormatHalftoneTag    =    FOUR_CHAR_CODE('half')
  139. };
  140.  
  141. /************************************* NEW STUFF *********************************/
  142. /************************************* NEW STUFF *********************************/
  143. /************************************* NEW STUFF *********************************/
  144. /************************************* NEW STUFF *********************************/
  145. /************************************* NEW STUFF *********************************/
  146. /************************************* NEW STUFF *********************************/
  147. /************************************* NEW STUFF *********************************/
  148. /************************************* NEW STUFF *********************************/
  149. /************************************* NEW STUFF *********************************/
  150. /* VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV*/
  151. /******************** ABSTRACT CLASSES FOR INTERACTING WITH THE WORLD ********************/
  152.  
  153. /*************
  154.     This class is for accessing the spool file.
  155.     The LaserWriter driver will have to subclass this
  156.     appropriately.
  157.     
  158.     This is called by the font database handler during spooling to save the 
  159.     database in the spool file and during despooling to read it back.
  160.     
  161. **************/
  162. class gxSpoolFile {
  163.     public:
  164.         gxSpoolFile() {};
  165.         virtual ~gxSpoolFile() {};
  166.         virtual OSErr    DespoolResource(OSType type, short ID, Handle *h) {return noErr;};
  167.         virtual OSErr    SpoolResource(Handle h, OSType type, short ID) {return noErr;};
  168.  
  169. };//gxSpoolFile
  170.  
  171.  
  172. /**************
  173.     This class is used by the GX To PostScript library
  174.     for doing I/O and other device specific functions.
  175.     
  176.     It is an abstract class which the client is responsible
  177.     for subclassing to perform the specified operations.
  178.     
  179.     Messages can be overridden in the following manner:
  180.     
  181.         Idle:                        This message is sent by the system to give up time to other processes.
  182.  
  183.         ReportStatus:        Various user messages are sent via this message.
  184.  
  185.         BufferData:            All PostScript is streamed through this message.  Typically, a client would take the
  186.                                         data passed to this method and insert it into its asynchronous I/O buffers.
  187.  
  188.         StreamFont:            This message is sent to download fonts.  It is NOT NECESSARY for the client to override this method
  189.                                         because the default implementation calls the OFA 1.0 calls in GXGraphics and takes the resulting
  190.                                         data and pipes it through the object's BufferData message.  However, it is overridable in case the client
  191.                                         has some other way of streaming font data.  NOT RECCOMENDED, HOWEVER!
  192.  
  193.         GetPrinterGlyphsInformation:
  194.                                     This message is sent by the system to find out what glyphs of a font are available on the printer.
  195.                                     The client can override this message and query the printer for the information, or it can query a PPD
  196.                                     file for the information.  Any glyphs not on the printer will be streamed (via the StreamFont message)
  197.                                     The default implementation reports that no glyphs are available.
  198.         
  199.         GetPSProduct:        This message is sent to find out the version/revision/product name of the printer.
  200.                                         The default implementation just returns "*" for all three.
  201.                                                                             
  202. ***************/
  203. class CGXtoPostScriptDevice {
  204.  
  205.     public:
  206.         CGXtoPostScriptDevice() {};
  207.         virtual             ~CGXtoPostScriptDevice() {};
  208.         
  209.         virtual            OSErr Idle() {return noErr;};
  210.         virtual            OSErr ReportStatus(long count, unsigned char message[]);
  211.         virtual            OSErr BufferData(char* data, long size, unsigned long flags) {return noErr;};
  212.         virtual             OSErr StreamFont(gxFont whatFont, scalerStream *streamRecord);
  213.         virtual            OSErr GetPrinterGlyphsInformation(gxPrinterGlyphsRec *printerGlyphs);
  214.         virtual            OSErr GetPSProduct(Str255 version, Str255 revision, Str255 product);
  215.         
  216. };//CGXtoPostScriptDevice
  217.  
  218.  
  219. // This function is in the never shipped GXGraphics 1.2, so for our purposes we'll just return nil,
  220. //    The imaging engine code handles a nil result already, and uses ColorSync 1.0 stuff in this case.
  221. //       If the client would like this translator to use ColorSync 2.x to generate PostScript color space arrays
  222. //        and CRD's rather than using the built in code based on ColorSync 1.x, then the client could
  223. //        tag the GX color profile object with a 2.0 profile and this routine could be rewritten
  224. //        to return the appropriate 2.0 profile.  (or a global profile could be returned in one is
  225. //        managed by the driver.
  226. inline  CMProfileRef    GXGetColorProfileReference(gxColorProfile source) {return nil;};
  227.  
  228.  
  229.  
  230.  
  231. #endif
  232.